package com.str.demo01;

public class Exam {
    public static void main(String[] args) {
        System.out.println("案例演示题目");
        String str = "this is a text";
        // 2 单独获取 转换为数组
        String[] arr = str.split(" ");
        for (String s : arr) {
            System.out.println(s);
        }

        // 3.将 str 中的text 替换成 china
        System.out.println(str.replace("text","china"));

        // 4.在text前面插入一个 easy
        System.out.println(str+"easy ");
        System.out.println(str.replace("text","easy text"));

        // 5.将每一个单词的首字母改为大写
        String new_str = "";
        for (int i = 0; i < arr.length; i++) {
            char f = arr[i].charAt(0);
            char upperfirst = Character.toUpperCase(f);
            new_str += upperfirst + arr[i].substring(1)+" ";
        }
        System.out.println(new_str);
    }
}
